{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from pythreejs import *\n",
    "from IPython.display import display"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Materials\n",
    "mat = MeshStandardMaterial(color='#ff0000')\n",
    "mat_green = MeshStandardMaterial(color='#00ff00')\n",
    "mat_blue = MeshStandardMaterial(color='#0000ff')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Geometries\n",
    "torus = TorusGeometry(radius=12, tube=3, radialSegments=16, tubularSegments=100)\n",
    "sphere = SphereGeometry(radius=12, _flat=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "bufferSphere = SphereBufferGeometry(radius=12, _flat=True)\n",
    "bufferTorus = TorusBufferGeometry(radius=12, tube=3, radialSegments=16, tubularSegments=100)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "sphere"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "bufferSphere"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Objects\n",
    "mesh = Mesh(geometry=torus, material=mat)\n",
    "sphereMesh = Mesh(geometry=sphere, material=mat_green)\n",
    "\n",
    "left = Mesh(geometry=sphere, material=mat, position=[-10, 0, 0])\n",
    "center = Mesh(geometry=sphere, material=mat_green)\n",
    "right = Mesh(geometry=sphere, material=mat_blue, position=[10, 0, 0])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Scenes\n",
    "scene = Scene()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "scene.add(left)\n",
    "scene.add(center)\n",
    "scene.add(right)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Cameras\n",
    "cam = PerspectiveCamera(position=[0, 0, 50], fov=75)\n",
    "cam.lookAt([0, 0, 0])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "scene.add(cam)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Lights\n",
    "amb = AmbientLight(color=\"#ffffff\", intensity=0.5)\n",
    "\n",
    "point = PointLight(color=\"#ffffff\", intensity=1.0, distance=0.0)\n",
    "point.position = [ -100, 100, 100 ]\n",
    "point.lookAt([0, 0, 0])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "cam.add(amb)\n",
    "cam.add(point)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Renderer\n",
    "renderer = WebGLRenderer()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "renderer"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "renderer.render(scene, cam)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "renderer.freeze()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "anaconda-cloud": {},
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.5.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
